package com.yxkj.syh.app.huarong.data_center.model;

import com.syh.app.basic.config.BasicConstants;
import com.syh.app.basic.utils.net.ApiObserver;
import com.yxkj.syh.app.huarong.bean.Linkman;
import com.yxkj.syh.app.huarong.util.RetrofitHelper;
import com.trello.rxlifecycle2.LifecycleTransformer;
import com.yxkj.syh.app.huarong.api.CommonApi;
import com.yxkj.syh.app.huarong.bean.PagesRequest;

import java.util.Map;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * 创建者：SYH
 * 时间：2020/5/22 13:57
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class CommonModel {
    private static CommonModel commonModel;

    private CommonModel() {
    }

    public static CommonModel getCommonModel() {
        if (commonModel == null) commonModel = new CommonModel();
        return commonModel;
    }


    public void notice(PagesRequest request,LifecycleTransformer transformer, ApiObserver apiObserver) {
        RetrofitHelper.createApi(CommonApi.class, BasicConstants.HOST).notice(request).compose(transformer).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(apiObserver);
    }

    public void linkList(PagesRequest request,LifecycleTransformer transformer, ApiObserver apiObserver) {
        RetrofitHelper.createApi(CommonApi.class).linkList(request).compose(transformer).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(apiObserver);
    }
    public void linkInfo(long id,LifecycleTransformer transformer, ApiObserver apiObserver) {
        RetrofitHelper.createApi(CommonApi.class).linkInfo(id).compose(transformer).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(apiObserver);
    }
    public void saveLinkman(Linkman linkman, LifecycleTransformer transformer, ApiObserver apiObserver) {
        RetrofitHelper.createApi(CommonApi.class).saveLinkman(linkman).compose(transformer).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(apiObserver);
    }

    public void msgList(PagesRequest request,LifecycleTransformer transformer, ApiObserver apiObserver) {
        RetrofitHelper.createApi(CommonApi.class).msgList(request).compose(transformer).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(apiObserver);
    }

    public void versionCheck(String packName,int platform,LifecycleTransformer transformer, ApiObserver apiObserver) {
        RetrofitHelper.createApi(CommonApi.class,BasicConstants.HOST).versionCheck(packName,platform).compose(transformer).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(apiObserver);
    }


}
